#! /usr/bin/perl
use strict;
use warnings FATAL => 'all';
use Search::Elasticsearch();

our $VERSION = '5.02';

#my $e = Search::Elasticsearch->new();
my @nodes = ['192.168.11.99:9300'];
my $e = Search::Elasticsearch->new(
    nodes    => \@nodes,
    plugins  => ['Xpack'],
    userinfo => "username:password"
);

my $response = $e->shield->authenticate();
print $response->{username};



#my $exist_1 = $e->exists(
#index => 'my_app',
#type => 'blog_post',
#id => 1
#);
#
#if(! $exist_1) {
#    $e->index(
#        index => 'my_app',
#        type => 'blog_post',
#        id => 1,
#        body => {
#            title => 'Elasticsearch clients',
#            content => 'Interesting content...',
#            date => '2017-01-02'
#        }
#    );
#}
#
#my $doc = $e->get(
#    index => 'my_app',
#    type => 'blog_post',
#    id => 1
#);
#
#print $doc->{_version} . "\n";
#print "title:   " . $doc->{_source}->{title} . "\n";
#print "content: " . $doc->{_source}->{content} . "\n";
#print "date:    " . $doc->{_source}->{date} . "\n";
